package com.yztc.orangeentertainment.ui.main.findfragment.findpersenter;

import android.content.Context;

import com.yztc.orangeentertainment.bean.findbean.SearchListBean;
import com.yztc.orangeentertainment.config.SubscribeUrlConfig;
import com.yztc.orangeentertainment.ui.main.findfragment.findmodel.ISearchModle;
import com.yztc.orangeentertainment.ui.main.findfragment.findmodel.OnLoadSearchListener;
import com.yztc.orangeentertainment.ui.main.findfragment.findmodel.SearchModle;
import com.yztc.orangeentertainment.ui.main.findfragment.findview.ISearchView;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by My on 2016/10/8.
 */
public class SearchPresenter {
    private ISearchModle modle;
    private ISearchView view;

    public SearchPresenter(ISearchView view) {
        this.view = view;
        this.modle = new SearchModle();
    }

    public void getSearchFromNet(Context context) {
        Map<String, String> map = new HashMap<>();
        map.put(SubscribeUrlConfig.Params.MAC, SubscribeUrlConfig.All_DefaultVaule.MAC_VALUE);
        map.put(SubscribeUrlConfig.Params.UID, SubscribeUrlConfig.All_DefaultVaule.UID_VALUE);
        map.put(SubscribeUrlConfig.Params.PF, SubscribeUrlConfig.All_DefaultVaule.PF_VALUE);
        map.put(SubscribeUrlConfig.Params.NET, SubscribeUrlConfig.All_DefaultVaule.NET_VALUE);
        map.put(SubscribeUrlConfig.Params.ACCESSTOKEN, SubscribeUrlConfig.All_DefaultVaule
                .ACCESSTOKEN_VALUE);
        map.put(SubscribeUrlConfig.Params.CHANNEL, SubscribeUrlConfig.All_DefaultVaule
                .CHANNEL_VALUE);
        map.put(SubscribeUrlConfig.Params.VER, SubscribeUrlConfig.All_DefaultVaule.VER_VALUE);
        map.put(SubscribeUrlConfig.Params.RES, SubscribeUrlConfig.All_DefaultVaule.RES_VALUE);

        modle.LoadSearchData("index", map, new OnLoadSearchListener() {
            @Override
            public void getSearchListBeanList(List<SearchListBean> searchListBeens) {
                view.setSearchList(searchListBeens);
            }

            @Override
            public void onFailure(Exception e) {
                view.onVerticalFail(e.getMessage());
            }
        });
    }
}
